# 默认参数
def power(x, n=2):  # 默认参数(缺省参数)n=2
    return x ** n


print(power(2, 3))
print(power(2))

print(int('16', 8))


def travel(dep, arr="南京", num=1):
    return "本次旅行，从%s出发，到达%s，共%d人" % (dep, arr, num)


t = travel("上海")
print(t)
t = travel("上海", "拉萨")
print(t)
t = travel("上海", num=2)
print(t)


# 可变参数
# def total(arr):
#     result = 0
#     for i in arr:
#         result += i
#     return result
#
# a = [1, 2, 3, 4, 5]
# print(total(a))
def total(*args):  # 可变参数，元组形式
    result = 0
    for i in args:
        result += i
    return result
# print(total(1, 2, 3, 4, 5))
a = [1, 2, 3, 4, 5]
print(*a)


def f(**kwargs):  # 可变函数，接收字典
    for k,v in kwargs.items():
        print(k, v)
d = {"name": "zhangsan", "age": 18}
f(**d)